#include "Cards.h"
#include "Card.h"
#include "Play.h"
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <unistd.h>
using namespace std;
static Cards m_allCards;
// 生成指定范围内的随机整数
void initAllCards()
{
    m_allCards.clear();
    for (int p = (int)Card::Rank::Three; p < (int)Card::Rank::Rand_size ; ++p) {
        for (int s = (int)Card::Suit::Hearts ;s<(int)Card::Suit::Suit_size ; ++s) {
            m_allCards.add(Card((Card::Rank)p,(Card::Suit)s));
        }
    }
    m_allCards.add(Card(Card::Rank::Joker_min, Card::Suit::Joker));
    m_allCards.add(Card(Card::Rank::Joker_max, Card::Suit::Joker));
}

// 将 Suit 枚举值转换为字符串的函数
std::string suitToString(Card::Suit suit) {
    switch (suit) {
        case Card::Suit::Hearts:
            return "♥";
        case Card::Suit::Diamonds:
            return "♦";
        case Card::Suit::Clubs:
            return "♣";
        case Card::Suit::Spades:
            return "♠";
        case Card::Suit::Joker:
            return "王";
    }
}
void printCards(const Cards& Cards) {
    int i=0;
    for(auto it = Cards.m_cards.begin(); it != Cards.m_cards.end(); it++) {
        int a = (int)(*it).getRank();
        cout << a  << suitToString((*it).getSuit()) << " "; 
    }
    cout << endl << Cards.m_cards.size() << endl;
}

int main() {
  
    initAllCards();
    Player p;
    
    // auto it = m_allCards.m_cards.begin();
    cout << m_allCards.cardCount() << endl;
    for(int i = 0; i < 54; i++)  {
        Card a1s = m_allCards.takeRandomCard();
        if( i < 17 ) {
            p.storeDispatchCard(a1s);
        } 
        if( i % (51 / 3) == 0) {
            cout << endl;
        } 
        int a = (int)a1s.getRank();
        cout << a  << suitToString(a1s.getSuit()) << " "; 
    }
    cout << endl;

    printCards(p.getCards());
    return 0;
}
